package com.xmb.wechat.bean;

import com.chad.library.adapter.base.entity.MultiItemEntity;

import java.io.Serializable;
import java.util.Date;

import io.objectbox.annotation.Entity;
import io.objectbox.annotation.Id;
import io.objectbox.relation.ToMany;

@Entity
public class WechatMsgBean implements Serializable, MultiItemEntity {
    public static final int MSG_TYPE_STRING          = 1;//文字消息
    public static final int MSG_TYPE_IMG             = 2;//图片消息
    public static final int MSG_TYPE_VOICE           = 3;//语音
    public static final int MSG_TYPE_RED_PKG         = 4;//红包
    public static final int MSG_TYPE_TIME            = 5;//时间
    public static final int MSG_TYPE_SYS_TIP         = 6;//系统提示
    public static final int MSG_TYPE_VIDEO_CALL      = 7;//视频通话
    public static final int MSG_TYPE_VOICE_CALL      = 8;//语音通话
    public static final int MSG_TYPE_ZHUAN_ZHANG     = 9;//转账
    public static final int MSG_TYPE_RED_PKG_RECEIVE = 10;//红包领取，注意与MSG_TYPE_RED_PKG的区别
    public static final int MSG_TYPE_BUINESS_CARDS   = 11;//名片

    @Id
    private long id;
    //父ID，用于：领取转账的记录的PID指向转账的记录
    private long pid;
    //消息类型：文字；红包；日期；语音；转账；系统揭示；图片...
    private int  msgType;

    //发送消息的人：
    private long msgSenderID = -1; //-1我发的；非-1别人发的

    private Date   msgTime;
    private String content;
    //排序用的：
    private int    sortIndex;

    //是否是群聊
    private boolean isRoomChat;
    //聊天对象的ID，可能是个人或者群(看isRoomChat的值)
    private long    talkerID;
    //是否已读：
    private boolean isRead;

    //*************************
    //***转账、红包共有字段***
    //*************************
    //发起转账的人：-1我操作 非-1对方操作
    private long    moneySenderID;
    //转账、红包金额
    private double  money;
    //备注文字
    private String  moneyRemark;
    //是否已经收钱
    private boolean isReceiveMoney;

    //收款时间：
    private Date receiveTime;

    //*************************
    //***红包***
    //*************************
    //红包领取详情：
    public ToMany<WechatRedPkgReceiveBean> redPkgReceives;

    //名片
    private long    businessCardsId;

    //群红包收取
    private boolean isReceiveFinish;


    public boolean isRead() {
        return isRead;
    }

    public void setRead(boolean read) {
        isRead = read;
    }

    public long getPid() {
        return pid;
    }

    public void setPid(long pid) {
        this.pid = pid;
    }

    public Date getReceiveTime() {
        return receiveTime;
    }

    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }

    public boolean isMySend() {
        return msgSenderID == -1;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getMsgType() {
        return msgType;
    }

    public void setMsgType(int msgType) {
        this.msgType = msgType;
    }

    public Date getMsgTime() {
        return msgTime;
    }

    public void setMsgTime(Date msgTime) {
        this.msgTime = msgTime;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getSortIndex() {
        return sortIndex;
    }

    public void setSortIndex(int sortIndex) {
        this.sortIndex = sortIndex;
    }

    public boolean isRoomChat() {
        return isRoomChat;
    }

    public void setRoomChat(boolean roomChat) {
        isRoomChat = roomChat;
    }

    public long getTalkerID() {
        return talkerID;
    }

    public void setTalkerID(long talkerID) {
        this.talkerID = talkerID;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    public String getMoneyRemark() {
        return moneyRemark;
    }

    public void setMoneyRemark(String moneyRemark) {
        this.moneyRemark = moneyRemark;
    }

    public boolean isReceiveMoney() {
        return isReceiveMoney;
    }

    public void setReceiveMoney(boolean receiveMoney) {
        isReceiveMoney = receiveMoney;
    }

    public ToMany<WechatRedPkgReceiveBean> getRedPkgReceives() {
        return redPkgReceives;
    }

    public void setRedPkgReceives(ToMany<WechatRedPkgReceiveBean> redPkgReceives) {
        this.redPkgReceives = redPkgReceives;
    }

    public long getMsgSenderID() {
        return msgSenderID;
    }

    public void setMsgSenderID(long msgSenderID) {
        this.msgSenderID = msgSenderID;
    }

    public long getMoneySenderID() {
        return moneySenderID;
    }

    public void setMoneySenderID(long moneySenderID) {
        this.moneySenderID = moneySenderID;
    }

    @Override
    public int getItemType() {
        return isMySend() ? getMsgType() : getMsgType() * -1;
    }

    public long getBusinessCardsId() {
        return businessCardsId;
    }

    public void setBusinessCardsId(long businessCardsId) {
        this.businessCardsId = businessCardsId;
    }

    public boolean isReceiveFinish() {
        return isReceiveFinish;
    }

    public void setReceiveFinish(boolean receiveFinish) {
        isReceiveFinish = receiveFinish;
    }

    @Override
    public String toString() {
        return "WechatMsgBean{" +
                "id=" + id +
                ", pid=" + pid +
                ", msgType=" + msgType +
                ", msgSenderID=" + msgSenderID +
                ", msgTime=" + msgTime +
                ", content='" + content + '\'' +
                ", sortIndex=" + sortIndex +
                ", isRoomChat=" + isRoomChat +
                ", talkerID=" + talkerID +
                ", isRead=" + isRead +
                ", moneySenderID=" + moneySenderID +
                ", money=" + money +
                ", moneyRemark='" + moneyRemark + '\'' +
                ", isReceiveMoney=" + isReceiveMoney +
                ", receiveTime=" + receiveTime +
                ", redPkgReceives=" + redPkgReceives +
                ", businessCardsId=" + businessCardsId +
                ", isReceiveFinish=" + isReceiveFinish +
                '}';
    }
}
